from com.inductiveautomation.ignition.gateway import IgnitionGateway


class Window:
	
	
	def __init__(self):
		
		pass
		
		
	def getProjectPath(self, project):
		context = IgnitionGateway.get()
		projectParentFolder = str(context.systemManager.dataDir.absoluteFile).replace('\\','/') + '/projects/'
		
		return projectParentFolder + project + "/"
	
	
	def getFolderPath(self, folder):
		return "com.inductiveautomation.vision/windows/"+folder + "/"
		
	def getWindowPath(self, window):
		
		project = "Greenhouse"
		folder = "template"
		
		path = self.getProjectPath(project) + self.getFolderPath(folder) + window + "/window.xml"
		system.file.writeFile(path, Generate.Template.Vision.window.strip())
		
		
		path = self.getProjectPath(project) + self.getFolderPath(folder) + window + "/resource.json"
		system.file.writeFile(path, Generate.Template.Vision.resource.strip())
		
		
		path = self.getProjectPath(project) + self.getFolderPath(folder) + window + "/thumbnail.png"
		system.file.writeFile(path, None)
		
		system.project.requestScan(30)
		
		return path
		
	def write(self):
		pass